package demo13;

import java.util.Arrays;

/**
 * Created by Administrator on 2017/5/11.
 */
public class GetCon {
    public static void main(String[] args) {
        String str = "We are students";
        int size = str.length();
        System.out.println(size);
        int size2=str.indexOf("a");
        System.out.println(size2);
        int size3=str.lastIndexOf("e");
        System.out.println(size3);
        int size4 =str.lastIndexOf("");
        System.out.println(size4);
        System.out.println("------------------");
        String str2="hello word";
        char mychar=str2.charAt(6);
        String substr = str2.substring(3);
        String substr2 = str2.substring(0,3);
        System.out.println("字符串str中索引位置是6的字符为: "+mychar);
        System.out.println(substr);
        System.out.println(substr2);
        System.out.println("------------------");
        String str3=" Java class ";
        System.out.println("字符串原来的长度："+str3.length());
        System.out.println("去掉空格后的长度：" + str3.trim().length());
        System.out.println("------------------");
        String str4="address";
        String str5="java project";
        String newStr=str4.replace("a","A");
        String newStr2=str5.replace("j","J");
        System.out.println(newStr);
        System.out.println(newStr2);
        System.out.println("------------------");
        int arr[] = new int[]{4,25,10};
        Arrays.sort(arr);
        int index=Arrays.binarySearch(arr,0,1,8);
        System.out.println(index);
    }

}
